home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / t / run.t < prev   
Encoding:
Text File  |  1999-12-10  |  2.4 KB  |  116 lines

  1. use Config;
  2. use vars qw($EXTENSIVE_TESTS $GIMPTOOL);
  3.  
  4. # the most complicated thing is to set up a working gimp environment. its
  5. # difficult at best...
  6.  
  7. BEGIN {
  8.   $|=1;
  9.  
  10.   if ($ENV{DISPLAY}) {
  11.      print "1..26\n";
  12.      $count=0;
  13.      $Gimp::host = "spawn/";
  14.   } else {
  15.      print "1..0\n";
  16.      exit;
  17.   }
  18. }
  19.  
  20. sub ok($;$) {
  21.    print((@_==1 ? shift : $_[0] eq &{$_[1]}) ?
  22.          "ok " : "not ok ", ++$count, "\n");
  23. }
  24.  
  25. sub skip($$;$) {
  26.    shift() ? print "ok ",++$count," # skip\n" : &ok;
  27. }
  28.  
  29. END {
  30.   system("rm","-rf",$dir);#d##FIXME#
  31. }
  32.  
  33. use Cwd;
  34.  
  35. $dir=cwd."/test-dir";
  36.  
  37. do './config.pl';
  38. ok(1);
  39.  
  40. $n=!$EXTENSIVE_TESTS;
  41.  
  42. skip($n,1,sub {($plugins = `$GIMPTOOL -n --install-admin-bin /bin/sh`) =~ s{^.*\s(.*?)(?:/+bin/sh)\r?\n?$}{$1}});
  43. skip($n,1,sub {-d $plugins});
  44. skip($n,1,sub {-x "$plugins/script-fu"});
  45.  
  46. use Gimp;
  47. ok(1);
  48.  
  49. ok(RGBA_IMAGE || RGB_IMAGE);
  50. ok(RGB_IMAGE ? 1 : 1); #  check for correct prototype
  51.  
  52. sub tests {
  53.    my($i,$l);
  54.    skip($n,1,sub{0 != ($i=new Image(10,10,RGB))});
  55.    skip($n,1,sub {!!ref $i});
  56.    skip($n,1,sub{0 != ($l=$i->layer_new(10,10,RGBA_IMAGE,"new layer",100,VALUE_MODE))});
  57.    skip($n,1,sub {!!ref $l});
  58.    
  59.    skip($n,1,sub{Gimp->image_add_layer($l,0) || 1});
  60.    skip($n,"new layer",sub{$l->get_name()});
  61.    
  62.    skip($n,1,sub{$l->paintbrush(50,[1,1,2,2,5,3,7,4,2,8],CONTINUOUS,0) || 1});
  63.    skip($n,1,sub{$l->paintbrush(30,4,[5,5,8,1],CONTINUOUS,0) || 1});
  64.    
  65.    skip($n,1,sub{Plugin->sharpen(RUN_NONINTERACTIVE,$i,$l,10) || 1});
  66.    skip($n,1,sub{$l->sharpen(10) || 1});
  67.    skip($n,1,sub{Gimp->plug_in_sharpen($i,$l,10) || 1});
  68.    
  69.    skip($n,1,sub{$i->delete || 1});
  70. }
  71.  
  72. system("rm","-rf",$dir); #d#FIXME
  73. ok(1,sub {mkdir $dir,0700});
  74.  
  75. # copy the Perl-Server
  76. {
  77.    local(*X,*Y,$/);
  78.    open X,"<Perl-Server" or die "unable to read the Perl-Server";
  79.    my $s = <X>;
  80.    open Y,">$dir/Perl-Server.pl" or die "unable to write the Perl-Server";
  81.    print Y $Config{startperl},"\n",$s,<X>;
  82.    ok(1);
  83. }
  84. ok(1,sub { chmod 0700,"$dir/Perl-Server.pl" });
  85.  
  86. skip($n,1,sub {symlink "$plugins/script-fu","$dir/script-fu"});
  87. skip($n,1,sub {symlink "$plugins/sharpen","$dir/sharpen"});
  88.  
  89. ok (
  90.   open RC,">$dir/gimprc" and
  91.   print RC "(show-tips no)\n" and
  92.   print RC "(gimp_data_dir \"\")\n" and
  93.   print RC "(script-fu-path \"\")\n" and
  94.   print RC "(plug-in-path \"$dir\")\n" and
  95.   close RC
  96. );
  97.  
  98. $ENV{GIMP_DIRECTORY}=$dir;
  99. $ENV{PERL5LIB}=cwd."/blib/lib:".cwd."/blib/arch";
  100.  
  101. if(!$n) {
  102.    skip($n,1);
  103.    Gimp::init;
  104.    tests;
  105. } else {
  106.    skip($n,0);
  107.    tests;
  108. }
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.